<?php

namespace app\modules\backend\controllers;

use Yii;
use app\tools\Re;
use app\models\Setting;

class SettingController extends BaseController
{
    public function actionGetSettingInfo(){
      $setting_info = Setting::findOne(1);
      return Re::data(['data' => $setting_info]);
    }

    public function actionSaveSettingInfo(){
      $order_receive = Yii::$app->request->post('order_receive', 7);
      $order_success = Yii::$app->request->post('order_success', 7);
      $setting_info = Setting::findOne(1);
      $setting_info->order_receive = (int)$order_receive;
      $setting_info->order_success = (int)$order_success;
      if (!$setting_info->save()) {
        return Re::data(null, $setting_info->showErrors(), Re::ERROR);
      }
      return Re::data();
    }
}
